<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script src="../lib/vue.js"></script>
		<script src="../lib/jbase64.js"></script>
	</head>

	<body>
		<div id="app">
			{{ message }}
		</div>
		<div id="app-6">
			<p>{{ message }}</p>
			<input v-model="message">
		</div>
		<input id="input1" v-model="message">
		<div id="app-7">
			<p v-if="!showApp7" @click="showApp7=true">{{ message }}</p>
			<input v-model="message" v-if="showApp7" @keyup.enter="showApp7=false" @blur="showApp7=false"/>
			<button @click="saveValue">保存参数</button>
		</div>
	</body>

	<script>
		let initData = {
			showApp7: false,
			message: 'Hello Vue!'
		};
		let url = location.href;
		console.log("aa:" + url)
		let values = url.split('?')[1];
		console.log(values);
//		values = '{"showApp7":false,"message": "Hello Vue!"}'
//		var base64 = BASE64.encoder(values); //返回编码后的字符
//		console.log(base64)
		if(values != undefined) {
			var unicode = BASE64.decoder(values); //返回会解码后的unicode码数组。
			console.log(unicode)
			let str = '';
//			for(let i = 0, len = unicode.length; i < len; ++i) {
//				str += String.fromCharCode(unicode[i]);
//			}
			str = BASE64.decoderStr(values);
			initData = JSON.parse(str);
		}
		console.log(initData)
		var app = new Vue({
			el: '#app',
			data: {
				message: 'Hello Vue!'
			}
		});
		var app6 = new Vue({
			el: '#app-6',
			data: {
				message: 'Hello Vue!'
			}
		});
		var input1 = new Vue({
			el: '#input1',
			data: {
				message: 'Hello Vue!'
			},
			on: {
				click: function (event) {
					console.log("ddd")
				}
			}
		});
		var app7 = new Vue({
			el: '#app-7',
			data: 
			initData,
//			{
//				showApp7: false,
//				message: 'Hello Vue!'
//			},
			methods: {
				saveValue: function() {
					let dataStr = JSON.stringify(this.$data);
					console.log(dataStr);
					let base64 = BASE64.encoder(dataStr); //返回编码后的字符
					console.log(base64)
					location.href = location.href.split("?")[0]+"?"+base64;
				}
			}
		});
	</script>

</html>